package com.cloud.ceshi.api.factory;

import com.cloud.common.core.domain.R;
import com.cloud.ceshi.api.RemoteCeshiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 用户服务降级处理
 * 
 * @author cloud
 */
@Component
public class RemoteCeshiFallbackFactory implements FallbackFactory<RemoteCeshiService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteCeshiFallbackFactory.class);

    @Override
    public RemoteCeshiService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteCeshiService()
        {
            @Override
            public R list(@PathVariable("ddd") Integer ddd) {
                return R.fail("获取用户失败:" + throwable.getMessage());
            }

        };
    }
}
